import { createSSRApp } from "vue";
import App from "./App.vue";

export function createApp() {
  const app = createSSRApp(App);
  
  // uniapp路由守卫
  const list = ['pages/login/index']
  uni.addInterceptor('navigateTo', {
    invoke(e) {
      if (!list.includes(e.url)) {
        const token = uni.getStorageSync('token')
        if (!token) {
          uni.redirectTo({
            url: '/pages/login/index'
          })
          return false
        }
      }
      return true
    }
  })
  
  return {
    app
  };
}
